<template>
  <div class="box">
    <div
      :class="['list-item', activeIndex === index ? 'active' : '']"
      v-for="(item, index) in data"
      :key="item.id"
      @click="item.cb"
    >
      <i class="el-icon-arrow-right" style="margin-right: 10px"></i>
      <el-icon>
        <img :src="activeIndex === index ? item.activeIcon : item.icon" alt="" />
      </el-icon>
      <span class="text">{{ item.title }}</span>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { surveyAreaAndLine } from '../../../api/gis2d/maputils'
const { measure, clearMeasure } = surveyAreaAndLine();
const data = [
  {
    id: 1,
    title: '测距',
    icon: '/static/icon/测距-默认@1x.png',
    activeIcon: '/static/icon/测距-当前@1x.png',
    cb: () => {
      measure('distence')
    }
  },
  {
    id: 2,
    title: '测面',
    icon: '/static/icon/测面-默认@1x.png',
    activeIcon: '/static/icon/测面-当前@1x.png',
    cb: () => {
      measure('area')
    }
  },
  {
    id: 3,
    title: '清除测量',
    icon: '/static/icon/清除测量-默认@1x.png',
    activeIcon: '/static/icon/清除测量-当前@1x.png',
    cb: () => clearMeasure()
  }
];
const activeIndex = ref(-1)
</script>



<style lang="scss" scoped>
.box {
  height: 100%;
  padding: 46px 0px;
  overflow-y: auto;
  font-size: 20px;
  color: #b9eeff;
  .list-item {
    height: 60px;
    display: flex;
    align-items: center;
    cursor: pointer;
    padding-left: 35px;
    box-sizing: border-box;
  }
  .text {
    margin-left: 25px;
  }
  .list-item:hover {
    background: rgba(0, 19, 39, 0.5);
    color: #01c2ff;
  }
  .active {
    background: rgba(0, 19, 39, 0.5);
    color: #01c2ff;
  }
}
</style>


